home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / nindy-share / ttyflush.c < prev    next >
C/C++ Source or Header  |  1992-09-11  |  2KB  |  54 lines

  1. /*****************************************************************************
  2.  *         Copyright (c) 1990, Intel Corporation
  3.  *
  4.  * Intel hereby grants you permission to copy, modify, and 
  5.  * distribute this software and its documentation.  Intel grants
  6.  * this permission provided that the above copyright notice 
  7.  * appears in all copies and that both the copyright notice and
  8.  * this permission notice appear in supporting documentation.  In
  9.  * addition, Intel grants this permission provided that you
  10.  * prominently mark as not part of the original any modifications
  11.  * made to this software or documentation, and that the name of 
  12.  * Intel Corporation not be used in advertising or publicity 
  13.  * pertaining to distribution of the software or the documentation 
  14.  * without specific, written prior permission.  
  15.  *
  16.  * Intel Corporation does not warrant, guarantee or make any 
  17.  * representations regarding the use of, or the results of the use
  18.  * of, the software and documentation in terms of correctness, 
  19.  * accuracy, reliability, currentness, or otherwise; and you rely
  20.  * on the software, documentation and results solely at your own risk.
  21.  *****************************************************************************/
  22.  
  23. static char rcsid[] =
  24.     "Id: ttyflush.c,v 1.1.1.1 1991/03/28 16:21:03 rich Exp $";
  25.  
  26. #include <stdio.h>
  27. #include <fcntl.h>    /* Needed on Sys V */
  28. #include "ttycntl.h"
  29.  
  30. /******************************************************************************
  31.  * tty_flush:
  32.  *
  33.  *    This routine puts the specified tty into a quiescent state by flushing
  34.  *    all pending input and output.
  35.  *
  36.  *    The tty is assumed to be connected to an i960 board containing a
  37.  *    a NINDY ROM;  since the 960 may be generating output, we wait until
  38.  *    at least one second goes by without anything new arriving.
  39.  ******************************************************************************/
  40.  
  41. tty_flush( fd )
  42.     int fd;    /* File descriptor of tty line */
  43. {
  44.     int n;    /* Number of characters of pending input */
  45.     char c;    /* Next character of input (discarded) */
  46.  
  47.     do {
  48.         TTY_FLUSH( fd );
  49.         sleep(1);
  50.         n = 1;
  51.         TTY_NBREAD( fd, n, &c );    /* Non-blocking read */
  52.     } while ( n > 0 );
  53. }
  54.